Part Number Hot Search : 
DUM34 MB88141A T711002 C2881 STM32F DB102 MT4435 Z25LA102
Product Description
Full Text Search
 

To Download AN1182 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN1182 / 0300 1/8 AN1182 application note using the st7 usb low-speed firmware by microcontroller division applications this application note describes how to use the st7_usb firmware. this firmware, written in c, using the hiware c compiler, provides a complete usb protocol layer for low-speed usb mi- crocontrollers (such as the st7262, st7263 and st72774). the source code is available free to stmicroelectronics customers. 1 overview the firmware files, supplied in a zip file, are organised in the directories shown in figure 1. figure 1. directory structure and contents of sources\appli in order to use the st7_usb_low_speed_firmware, you will only have to modify the files contained in the root and appli directory. you will not need to touch any of the files in the other directories (micro and usb). 1
2/8 using the st7 usb low-speed firmware 2 modifying the files in the root directory you must choose the .mak and .prm files corresponding to the device you are using. for example, if you are using a st72774 with 60k of rom, you have to open the file demo72774.mak and make sure that all references to .prm files use the name 72774_60k.prm. if you want to add some source files or directories, you have to customize them according to the application note an989 titled astarting with st7 hiware co. 3 modifying the files in the appli directory all the application-specific files have to be located in the appli directory. here is a description of the files that are in the directory initially: file name description condcomp.h compiler directives: product selection, clock frequency, lvd, watchdog, etc.... descript.c and .h descriptor files: you have to modify them according to your application (the initial values filled in apply to the st7263demokit) int_7263.c and .h or int72774.c and .h all the interrupt routines for your application have to be in one of these files (de- pends on the selected microcontroller). my_appli.c and .h your application has to be in this file with the name: ousb_applicationo. some hid class functions are also available in this file. the my_suspend and my_resume functions have to be completed in this file. my_init.c and .h your initialisation routine. usr_var.c and .h declaration of all your application variables. hid_appli.c and .h hid specific functions (like getreport &setreport) 2
3/8 using the st7 usb low-speed firmware 4 explanation of variables and functions as shown in figure 2, the usb protocol firmware, (which you do not have to modify) uses a certain number of variables and functions which you can also use in your application source files (directory /appli). these variables and functions are also used in the data transfer func- tions and interrupt routines (int_usb.c). figure 2. iinterdependancy of usb variables and functions usb_pollin g (usb protocol) usb_applica tion my_init.c reportida rrayin reportida rrayout out_datan umberepn wvalueh wvaluel usbinfo transmitep n(reportida rrayin,report_in_size) receiveep n(reportidarrayout) setepnrxstatus (status) getepnrxstatus (status) setepntxstatus (status) getepntxstatus (status) writetoep n(reportidarrayin,report_in_size) readfromepn(re portidarrayout) switchusbon switchusboff usb bus usb bus shared functions : shared variables : user software : n can be 1 or 2 depending on the application
4/8 using the st7 usb low-speed firmware 4.1 variables here is a description of the variables.the first one, reportidarray, is declared in the usr_var.c file, the others are declared in the usb_var.c file: 4.2 data transfer function calls to transfer data over the usb, include any of the function calls below in your application pro- gram. figure 3, figure 4 and figure 5 give flowcharts showing their use. variable description reportidarray_in reportidarray_out arrays used in the application index 0 => report id number index 1 to report_in_size (or report_out_size) => data report report_in_size report_out_size number of data bytes to exchange with the host out_datanumberep n number of data bytes received on endpoint number n wvalueh class report type used in setreport & getreport wvaluel report id number, used in getreport function usbinfo select product in multiple product & mode function description transmitep n (reportidarrayin,report_in_size) send data contained in reportidarrayin from device to host pc via endpoint number n receiveep n (reportidarrayout) put in reportidarrayout, the data received from the host pc via endpoint n setep n rxstatus(status) in reception, set endpoint n to valid, nak, stall or disable getep n rxstatus(status) in reception, get the status of endpoint n setep n txstatus(status) in transmission, set endpoint n to valid, nak, stall or disable getep n txstatus(status) in transmission, get the status of endpoint n writetoep n (reportidarrayin,report_in_size) put data on the usb buffer, ready to be sent, wait the validation of the ep n in transmission readfromep n (reportidarrayout) read data from the ep n buffer, the ep n still un- validated after the read. switchusbon switch on the st7 on-chip usb interface switchusboff switch off the st7 on-chip usb interface
5/8 using the st7 usb low-speed firmware 4.2.1 sending data to send data, the transmitep n function must be used. figure 3. transmitep n (thedatatosend,thenumberofdata) here is an example of the way the transmitep n () function has to be used: getep n txst atus = xx10xxxx (nak) ? put data in the endpoint n tx ram l ocat ion set the number of data t o send wi th the setep n txtbc f unct ion set endpoint n valid for transmissionwith the setep n txstatus function returnfail returnsuccess transmitep n (thedatatosend,thenumberofdata) yes no transmitep n (reportidarrayin, report_in_size) == success ? datasent = true how to transmit data yes no
6/8 using the st7 usb low-speed firmware 4.2.2 . receiving data figure 4. receiveep n (thedatareceived) figure 5. how to receive data getep n rxstatus = xx10xxxx (nak) ? put the recei ved data i n o therecei veddatao vari abl e setep n rxstatus(valid) to enable the r ecepti on on endpoi nt n return fail return success receiveep n (thereceiveddata) receiveep n ( thereceivedata) == success ? use the received data or store them in a specific variable how t o receive data yes no
7/8 using the st7 usb low-speed firmware 4.3 functions already available for hid class (in my_appli.c) you will find the following functions which have been defined in my_appli.c. examples: for the st7263 demo kit, the value of the button is linked to reportid 2, so the result of a ge- treport(2) is the button value. in the st7263 demo kit, the reportid of the pwm is 4, so a setreport[4,40] will set the st7263 pwm to a 40% duty cycle. function description build_feature_report get a specific feature of the device build_output_report get a specific value for an output feature getreport select the right function to call between getfeature and getoutput. process_feature_report set a specific feature of the device process_output_report set a specific output feature of the device setreport select the set report type
8/8 using the st7 usb low-speed firmware athe present note which is for guidance only aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connexion with their products.o information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publication are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroelectronics. the st logo is a registered trademark of stmicroelectronics ? 2000 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - china - finland - france - germany - hong kong - india - italy - japan - malaysia - malta - morocco - singapore - spain sweden - switzerland - united kingdom - u.s.a. http:// www.st.com


▲Up To Search▲   

 
Price & Availability of AN1182

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X